import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf


a = tf.Variable(initial_value=20.0)
b = tf.Variable(initial_value=30.0)

c = tf.add(a, b)

# 初始化变量
init = tf.compat.v1.global_variables_initializer()

# 开启会话
with tf.compat.v1.Session() as sess:
    # 变量初始化
    sess.run(init)
    print(sess.run(c))

"""
用tf.Variable定义的变量必须有初始化变量和变量初始化这两步，否则c不能正常打印
"""

